<template>
	<view>
		{{friendlyTime}}
	</view>
</template>

<script>
	import uniIm from '@/uni_modules/uni-im/sdk/index.js';
	export default {
		name:"time-day",
		props:['conversation'],
		data() {
			return {
				
			};
		},
		computed: {
		  friendlyTime() {
		    // 使得时间会随着心跳动态更新
		    let timestamp = this.conversation.time + uniIm.heartbeat * 0
		    let friendlyTime = uniIm.utils.toFriendlyTime(timestamp)
		    // console.log('friendlyTime',friendlyTime);
		    let friendlyTimeArr = friendlyTime.split(' ')
		    let friendlyTimeArrL = friendlyTimeArr.length
		    // 如果含 年/月（不在3天内，且不是同一周），去掉时间
		    if (friendlyTimeArrL == 3 && friendlyTime.includes('/')) {
		      friendlyTime = friendlyTimeArr[0]
		    }
		    return friendlyTime
		  }
		},
	}
</script>

<style>

</style>